﻿using System.Collections.Generic;
using System.Windows.Media;

namespace SHomeWorkshop.LunarTools
{
    public static class BrushManager
    {
        static BrushManager()
        {
            brushesList = new List<BrushItem>();

            brushesList.Add(new BrushItem(Brushes.AliceBlue, "AliceBlue", "爱丽丝蓝"));
            brushesList.Add(new BrushItem(Brushes.AntiqueWhite, "AntiqueWhite", "古董白"));
            brushesList.Add(new BrushItem(Brushes.Aqua, "Aqua", "水绿"));
            brushesList.Add(new BrushItem(Brushes.Aquamarine, "Aquamarine", "碧玉绿"));
            brushesList.Add(new BrushItem(Brushes.Azure, "Azure", "蔚蓝"));
            brushesList.Add(new BrushItem(Brushes.Beige, "Beige", "米色"));
            brushesList.Add(new BrushItem(Brushes.Bisque, "Bisque", "乳脂色"));
            brushesList.Add(new BrushItem(Brushes.Black, "Black", "黑色"));
            brushesList.Add(new BrushItem(Brushes.BlanchedAlmond, "BlanchedAlmond", "白杏色"));
            brushesList.Add(new BrushItem(Brushes.Blue, "Blue", "蓝色"));
            brushesList.Add(new BrushItem(Brushes.BlueViolet, "BlueViolet", "蓝紫罗兰色"));
            brushesList.Add(new BrushItem(Brushes.Brown, "Brown", "棕色"));
            brushesList.Add(new BrushItem(Brushes.BurlyWood, "BurlyWood", "坚树色"));
            brushesList.Add(new BrushItem(Brushes.CadetBlue, "CadetBlue", "军校蓝"));
            brushesList.Add(new BrushItem(Brushes.Chartreuse, "Chartreuse", "查特酒绿"));
            brushesList.Add(new BrushItem(Brushes.Chocolate, "Chocolate", "巧克力色"));
            brushesList.Add(new BrushItem(Brushes.Coral, "Coral", "珊瑚色"));
            brushesList.Add(new BrushItem(Brushes.CornflowerBlue, "CornflowerBlue", "矢车菊蓝"));
            brushesList.Add(new BrushItem(Brushes.Cornsilk, "Cornsilk", "玉米色"));
            brushesList.Add(new BrushItem(Brushes.Crimson, "Crimson", "猩红"));
            brushesList.Add(new BrushItem(Brushes.Cyan, "Cyan", "青色"));
            brushesList.Add(new BrushItem(Brushes.DarkBlue, "DarkBlue", "深蓝"));
            brushesList.Add(new BrushItem(Brushes.DarkCyan, "DarkCyan", "深青"));
            brushesList.Add(new BrushItem(Brushes.DarkGoldenrod, "DarkGoldenrod", "深金菊色"));
            brushesList.Add(new BrushItem(Brushes.DarkGray, "DarkGray", "深灰"));
            brushesList.Add(new BrushItem(Brushes.DarkGreen, "DarkGreen", "深绿"));
            brushesList.Add(new BrushItem(Brushes.DarkKhaki, "DarkKhaki", "深卡其布色"));
            brushesList.Add(new BrushItem(Brushes.DarkMagenta, "DarkMagenta", "深洋红"));
            brushesList.Add(new BrushItem(Brushes.DarkOliveGreen, "DarkOliveGreen", "深橄榄绿"));
            brushesList.Add(new BrushItem(Brushes.DarkOrange, "DarkOrange", "深橙色"));
            brushesList.Add(new BrushItem(Brushes.DarkOrchid, "DarkOrchid", "深兰花紫"));
            brushesList.Add(new BrushItem(Brushes.DarkRed, "DarkRed", "深红"));
            brushesList.Add(new BrushItem(Brushes.DarkSalmon, "DarkSalmon", "鲑鱼色"));
            brushesList.Add(new BrushItem(Brushes.DarkSeaGreen, "DarkSeaGreen", "深海绿"));
            brushesList.Add(new BrushItem(Brushes.DarkSlateBlue, "DarkSlateBlue", "深石板蓝"));
            brushesList.Add(new BrushItem(Brushes.DarkSlateGray, "DarkSlateGray", "深石板灰"));
            brushesList.Add(new BrushItem(Brushes.DarkTurquoise, "DarkTurquoise", "深宝石绿"));
            brushesList.Add(new BrushItem(Brushes.DarkViolet, "DarkViolet", "深紫罗兰色"));
            brushesList.Add(new BrushItem(Brushes.DeepPink, "DeepPink", "深粉色"));
            brushesList.Add(new BrushItem(Brushes.DeepSkyBlue, "DeepSkyBlue", "深天蓝"));
            brushesList.Add(new BrushItem(Brushes.DimGray, "DimGray", "暗灰"));
            brushesList.Add(new BrushItem(Brushes.DodgerBlue, "DodgerBlue", "道奇蓝"));
            brushesList.Add(new BrushItem(Brushes.Firebrick, "Firebrick", "耐火砖色"));
            brushesList.Add(new BrushItem(Brushes.FloralWhite, "FloralWhite", "花白"));
            brushesList.Add(new BrushItem(Brushes.ForestGreen, "ForestGreen", "森林绿"));
            brushesList.Add(new BrushItem(Brushes.Fuchsia, "Fuchsia", "灯笼海棠色"));
            brushesList.Add(new BrushItem(Brushes.Gainsboro, "Gainsboro", "庚斯博罗灰"));
            brushesList.Add(new BrushItem(Brushes.GhostWhite, "GhostWhite", "幽灵白"));
            brushesList.Add(new BrushItem(Brushes.Gold, "Gold", "金色"));
            brushesList.Add(new BrushItem(Brushes.Goldenrod, "Goldenrod", "金菊黄"));
            brushesList.Add(new BrushItem(Brushes.Gray, "Gray", "灰色"));
            brushesList.Add(new BrushItem(Brushes.Green, "Green", "绿色"));
            brushesList.Add(new BrushItem(Brushes.GreenYellow, "GreenYellow", "绿黄"));
            brushesList.Add(new BrushItem(Brushes.Honeydew, "Honeydew", "蜜色"));
            brushesList.Add(new BrushItem(Brushes.HotPink, "HotPink", "热粉色"));
            brushesList.Add(new BrushItem(Brushes.IndianRed, "IndianRed", "印度红"));
            brushesList.Add(new BrushItem(Brushes.Indigo, "Indigo", "靛青"));
            brushesList.Add(new BrushItem(Brushes.Ivory, "Ivory", "象牙色"));
            brushesList.Add(new BrushItem(Brushes.Khaki, "Khaki", "卡其布色"));
            brushesList.Add(new BrushItem(Brushes.Lavender, "Lavender", "熏衣草色"));
            brushesList.Add(new BrushItem(Brushes.LavenderBlush, "LavenderBlush", "熏衣草红"));
            brushesList.Add(new BrushItem(Brushes.LawnGreen, "LawnGreen", "草坪绿"));
            brushesList.Add(new BrushItem(Brushes.LemonChiffon, "LemonChiffon", "柠檬绸色"));
            brushesList.Add(new BrushItem(Brushes.LightBlue, "LightBlue", "浅蓝"));
            brushesList.Add(new BrushItem(Brushes.LightCoral, "LightCoral", "浅珊瑚色"));
            brushesList.Add(new BrushItem(Brushes.LightCyan, "LightCyan", "浅青色"));
            brushesList.Add(new BrushItem(Brushes.LightGoldenrodYellow, "LightGoldenrodYellow", "浅金菊黄"));
            brushesList.Add(new BrushItem(Brushes.LightGray, "LightGray", "浅灰"));
            brushesList.Add(new BrushItem(Brushes.LightGreen, "LightGreen", "浅绿"));
            brushesList.Add(new BrushItem(Brushes.LightPink, "LightPink", "浅粉色"));
            brushesList.Add(new BrushItem(Brushes.LightSalmon, "LightSalmon", "浅鲑鱼肉色"));
            brushesList.Add(new BrushItem(Brushes.LightSeaGreen, "LightSeaGreen", "浅海绿"));
            brushesList.Add(new BrushItem(Brushes.LightSkyBlue, "LightSkyBlue", "浅海蓝"));
            brushesList.Add(new BrushItem(Brushes.LightSlateGray, "LightSlateGray", "浅石板灰"));
            brushesList.Add(new BrushItem(Brushes.LightSteelBlue, "LightSteelBlue", "浅钢蓝"));
            brushesList.Add(new BrushItem(Brushes.LightYellow, "LightYellow", "浅黄"));
            brushesList.Add(new BrushItem(Brushes.Lime, "Lime", "酸橙色"));
            brushesList.Add(new BrushItem(Brushes.LimeGreen, "LimeGreen", "酸橙绿"));
            brushesList.Add(new BrushItem(Brushes.Linen, "Linen", "亚麻布色"));
            brushesList.Add(new BrushItem(Brushes.Magenta, "Magenta", "洋红"));
            brushesList.Add(new BrushItem(Brushes.Maroon, "Maroon", "栗色"));
            brushesList.Add(new BrushItem(Brushes.MediumAquamarine, "MediumAquamarine", "中碧玉绿"));
            brushesList.Add(new BrushItem(Brushes.MediumBlue, "MediumBlue", "中蓝"));
            brushesList.Add(new BrushItem(Brushes.MediumOrchid, "MediumOrchid", "中兰花紫"));
            brushesList.Add(new BrushItem(Brushes.MediumPurple, "MediumPurple", "中紫"));
            brushesList.Add(new BrushItem(Brushes.MediumSeaGreen, "MediumSeaGreen", "中海绿"));
            brushesList.Add(new BrushItem(Brushes.MediumSlateBlue, "MediumSlateBlue", "中石板蓝"));
            brushesList.Add(new BrushItem(Brushes.MediumSpringGreen, "MediumSpringGreen", "中春绿"));
            brushesList.Add(new BrushItem(Brushes.MediumTurquoise, "MediumTurquoise", "中宝石绿"));
            brushesList.Add(new BrushItem(Brushes.MediumVioletRed, "MediumVioletRed", "中紫罗兰红"));
            brushesList.Add(new BrushItem(Brushes.MidnightBlue, "MidnightBlue", "午夜蓝"));
            brushesList.Add(new BrushItem(Brushes.MintCream, "MintCream", "薄荷奶油色"));
            brushesList.Add(new BrushItem(Brushes.MistyRose, "MistyRose", "薄雾玫瑰色"));
            brushesList.Add(new BrushItem(Brushes.Moccasin, "Moccasin", "鹿皮色"));
            brushesList.Add(new BrushItem(Brushes.NavajoWhite, "NavajoWhite", "纳瓦白/土著白"));
            brushesList.Add(new BrushItem(Brushes.Navy, "Navy", "海军蓝"));
            brushesList.Add(new BrushItem(Brushes.OldLace, "OldLace", "旧蕾丝色"));
            brushesList.Add(new BrushItem(Brushes.Olive, "Olive", "橄榄色"));
            brushesList.Add(new BrushItem(Brushes.OliveDrab, "OliveDrab", "橄榄褐"));
            brushesList.Add(new BrushItem(Brushes.Orange, "Orange", "橙色"));
            brushesList.Add(new BrushItem(Brushes.OrangeRed, "OrangeRed", "橙红"));
            brushesList.Add(new BrushItem(Brushes.Orchid, "Orchid", "兰花紫"));
            brushesList.Add(new BrushItem(Brushes.PaleGoldenrod, "PaleGoldenrod", "灰金菊色"));
            brushesList.Add(new BrushItem(Brushes.PaleGreen, "PaleGreen", "灰绿"));
            brushesList.Add(new BrushItem(Brushes.PaleTurquoise, "PaleTurquoise", "灰宝石绿"));
            brushesList.Add(new BrushItem(Brushes.PaleVioletRed, "PaleVioletRed", "灰紫罗兰红"));
            brushesList.Add(new BrushItem(Brushes.PapayaWhip, "PapayaWhip", "番木瓜色"));
            brushesList.Add(new BrushItem(Brushes.PeachPuff, "PeachPuff", "桃色"));
            brushesList.Add(new BrushItem(Brushes.Peru, "Peru", "秘鲁色"));
            brushesList.Add(new BrushItem(Brushes.Pink, "Pink", "粉红"));
            brushesList.Add(new BrushItem(Brushes.Plum, "Plum", "李色"));
            brushesList.Add(new BrushItem(Brushes.PowderBlue, "PowderBlue", "粉蓝"));
            brushesList.Add(new BrushItem(Brushes.Purple, "Purple", "紫色"));
            brushesList.Add(new BrushItem(Brushes.Red, "Red", "红色"));
            brushesList.Add(new BrushItem(Brushes.RosyBrown, "RosyBrown", "玫瑰棕色"));
            brushesList.Add(new BrushItem(Brushes.RoyalBlue, "RoyalBlue", "皇室蓝"));
            brushesList.Add(new BrushItem(Brushes.SaddleBrown, "SaddleBrown", "重褐色"));
            brushesList.Add(new BrushItem(Brushes.Salmon, "Salmon", "鲑鱼肉色"));
            brushesList.Add(new BrushItem(Brushes.SandyBrown, "SandyBrown", "沙棕色"));
            brushesList.Add(new BrushItem(Brushes.SeaGreen, "SeaGreen", "海绿"));
            brushesList.Add(new BrushItem(Brushes.SeaShell, "SeaShell", "海贝色"));
            brushesList.Add(new BrushItem(Brushes.Sienna, "Sienna", "黄土赭"));
            brushesList.Add(new BrushItem(Brushes.Silver, "Silver", "银白"));
            brushesList.Add(new BrushItem(Brushes.SkyBlue, "SkyBlue", "天蓝"));
            brushesList.Add(new BrushItem(Brushes.SlateBlue, "SlateBlue", "石板蓝"));
            brushesList.Add(new BrushItem(Brushes.SlateGray, "SlateGray", "石板灰"));
            brushesList.Add(new BrushItem(Brushes.Snow, "Snow", "雪色"));
            brushesList.Add(new BrushItem(Brushes.SpringGreen, "SpringGreen", "春绿"));
            brushesList.Add(new BrushItem(Brushes.SteelBlue, "SteelBlue", "钢蓝"));
            brushesList.Add(new BrushItem(Brushes.Tan, "Tan", "茶色"));
            brushesList.Add(new BrushItem(Brushes.Teal, "Teal", " 水鸭绿"));
            brushesList.Add(new BrushItem(Brushes.Thistle, "Thistle", "蓟色"));
            brushesList.Add(new BrushItem(Brushes.Tomato, "Tomato", "番茄色"));
            brushesList.Add(new BrushItem(Brushes.Transparent, "Transparent", "透明色"));
            brushesList.Add(new BrushItem(Brushes.Turquoise, "Turquoise", "宝石绿"));
            brushesList.Add(new BrushItem(Brushes.Violet, "Violet", "紫罗兰色"));
            brushesList.Add(new BrushItem(Brushes.Wheat, "Wheat", "小麦色"));
            brushesList.Add(new BrushItem(Brushes.White, "White", "白色"));
            brushesList.Add(new BrushItem(Brushes.WhiteSmoke, "WhiteSmoke", "白烟色"));
            brushesList.Add(new BrushItem(Brushes.Yellow, "Yellow", "黄色"));
            brushesList.Add(new BrushItem(Brushes.YellowGreen, "YellowGreen", "黄绿"));
        }

        private static List<BrushItem> brushesList;

        public static List<BrushItem> BrushesList
        {
            get { return brushesList; }
        }

        public static Brush GetBrushByEnName(string enName)
        {
            if (enName == null) return null;

            foreach (BrushItem bi in brushesList)
            {
                if (bi.EnName == enName) return bi.Brush;
            }

            return null;
        }

        public static Brush GetBrushByCnName(string cnName)
        {
            if (cnName == null) return null;

            foreach (BrushItem bi in brushesList)
            {
                if (bi.EnName == cnName) return bi.Brush;
            }

            return null;
        }

        /// <summary>
        /// 取Brush的中文名称。
        /// </summary>
        /// <param name="brush">只能传入Brushes类中定义的Brush。</param>
        /// <returns></returns>
        public static string GetCnName(Brush brush)
        {
            if (brush == null) return null;

            foreach (BrushItem bi in brushesList)
            {
                if (brush==bi.Brush) return bi.CnName;
            }

            return null;
        }

        /// <summary>
        /// 取Brush的英文名称。
        /// </summary>
        /// <param name="brush">只能传入Brushes类中定义的Brush。</param>
        /// <returns></returns>
        public static string GetEnName(Brush brush)
        {
            if (brush == null) return null;

            foreach (BrushItem bi in brushesList)
            {
                if (brush == bi.Brush) return bi.EnName;
            }

            return null;
        }

        /// <summary>
        /// 根据英文名称取Brush的中文名称。
        /// </summary>
        /// <param name="brushEnName">只能传入Brushes类中定义的Brush的英文名称。</param>
        /// <returns></returns>
        public static string GetCnName(string brushEnName)
        {
            if (brushEnName == null) return null;

            foreach (BrushItem bi in brushesList)
            {
                if (brushEnName == bi.EnName) return bi.CnName;
            }

            return null;
        }

        /// <summary>
        /// 根据中文名称取Brush的英文名称。
        /// </summary>
        /// <param name="brushCnName">只能传入Brushes类中定义的Brush的中文名称。</param>
        /// <returns></returns>
        public static string GetEnName(string brushCnName)
        {
            if (brushCnName == null) return null;

            foreach (BrushItem bi in brushesList)
            {
                if (brushCnName == bi.CnName) return bi.EnName;
            }

            return null;
        }
    }

    public class BrushItem
    {
        public BrushItem(Brush bsh, string enName, string cnName)
        {
            this.brush = bsh;
            this.enName = enName;
            this.cnName = cnName;
        }

        private Brush brush = Brushes.Transparent;

        /// <summary>
        /// 默认是透明色。
        /// </summary>
        public Brush Brush
        {
            get { return brush; }
            set { brush = value; }
        }

        private string enName = "Transparent";

        public string EnName
        {
            get { return enName; }
        }

        private string cnName = "透明色";

        public string CnName
        {
            get { return cnName; }
        }
    }
}
